package com.hellowx_ssm.mybatis_spring.service.impl;

import com.hellowx_ssm.mybatis_spring.dao.UserDAO;
import com.hellowx_ssm.mybatis_spring.entity.User;
import com.hellowx_ssm.mybatis_spring.service.UserService;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * Created by IntelliJ IDEA.
 *
 * @author MagicMushroom
 * @date 2021/6/20
 */
@Transactional
public class UserServiceImpl implements UserService {
    private UserDAO userDAO;

    public UserDAO getUserDAO() {
        return userDAO;
    }

    public void setUserDAO(UserDAO userDAO) {
        this.userDAO = userDAO;
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
    public User login(User user) {
        return userDAO.selectByName(user.getName());
    }

    @Override
    public void register(User user) {
        userDAO.save(user);
//        throw new RuntimeException("测试");
    }
}
